package com.iot.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iot.domain.Device;
import com.iot.domain.Product;
import com.iot.service.IotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wlr
 * @since 2022-01-05
 */
@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    IotService iotService;

    @RequestMapping("queryProduct")
    public void queryProduct(){
        String str = iotService.queryProduct();
        JSONObject jsonObject = JSON.parseObject(str);
        JSONObject data = jsonObject.getJSONObject("data");
        String string = data.toJSONString();
        Product product = JSONArray.parseObject(string, Product.class);
        System.out.println(product);
//        JSONObject result = data.getJSONObject("result");
//
//        String organunit1 = result.getString("organunit");
//        System.out.println(organunit1);
//        JSONObject organunit = result.getJSONObject("organunit");
//
//        JSONArray errors2 = organunit.getJSONArray("errors");




    }
}

